﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BirdAnimController : MonoBehaviour {

	public enum State {
		Idle,
		Walk,
		Fly,
		FlyAction,
		Turn
	}

	Animator m_Animator;
	public State MState {
		get;
		set;
	}

	private void Awake() {
		m_Animator = gameObject.GetComponent<Animator>();
	}

	public void setMove(float move) {
		//MState = Mathf.Abs(move) > 1 ? State.Fly : State.Walk;
		MState = (State)move;
		m_Animator.SetFloat("Move", move);
	}

	public void StopState() {
		m_Animator.SetBool(MState.ToString(), false);
	}
	public void StopFlyAction() {
		m_Animator.SetBool(State.FlyAction.ToString(), false);
		MState = State.Fly;
	}


	public void PlayState(State name) {
		//Debug.Log(name + " : 播放动画" + name);

		if(name > State.Fly) {
			m_Animator.SetBool(MState.ToString(), false);
			m_Animator.SetBool(name.ToString(), true);
		} else {
			m_Animator.SetFloat("Move", (float)name);
		}
		MState = name;
	}

}
